package bairui.international.console.web.controller.spread.img;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianjing.sh.project.commons.util.Util_FileDeal;
import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.output.FomatOutput;

import bairui.international.model.domain.jpa.TB_SpreadImage;
import bairui.international.service.Service_SpreadImage;

/**
 *
 * 图片管理
 *
 * @generated
 * 
 * @see STest_C_Spread_Img_Manage_Edit 测试
 *
 */
@Controller
public class C_Spread_Img_Manage_Edit
 extends SC_Spread_Img_Manage_Edit 
{
	
	@Autowired private Service_SpreadImage service_SpreadImage;
	
	/**
	 * 编辑
	 */
	@Action(Edit.class)
	@PostMapping(Edit.RequestMappingValue)
	public @FomatOutput @ResponseBody Object edit(
		@Valid Edit.InputModel input, 
		@PathVariable(name=Edit.PathVariableName.ImgId) long imgId
	) throws Exception {
		TB_SpreadImage bean = service_SpreadImage.updateWithNonNullProperties(imgId, input);
		// 更新图片
		Util_FileDeal.updateFile(input.gainFileUrlFile(), bean.getFileUrl(), pathConfig.getPosition_Image_SpreadImage());
		//
		return null;
	}
	

}
